package com.doitedu.day01

import scala.util.control.Breaks

/**
 * @Date 22.6.19
 * @Created by HANGGE
 * @Description
 */
object  _05控制循环停止 {
  def main(args: Array[String]): Unit = {
    // 控制工具类
    val breaks = new Breaks
    breaks.breakable{
      for (i <- 1  to 10 ){
        println(i)
        //循环终止
        if (i == 5) {
          breaks.break()
        }
      }
    }

/*    var flag = true
    for (i <- 1  to 10 if flag){
      println(i)
      //循环终止
    if (i == 5) {
        flag = false
      }
    }
    println("还有逻辑..........")
  */




  }

}
